using System;
using System.Collections.Generic;
using System.Text;
using DAL;
using DTO;
using BUS;
using Utility;

namespace BUS
{
  public   class TinhTrang_Phieu_BUS
    {
      public static void Insert(TinhTrang_Phieu_DTO Phieu)
        {
            TinhTrang_Phieu_DAL Phieu_DAL = new TinhTrang_Phieu_DAL();
            Phieu_DAL.Insert(Phieu);
        }
      public static void Update(TinhTrang_Phieu_DTO Phieu)
        {
            TinhTrang_Phieu_DAL Phieu_DAL = new TinhTrang_Phieu_DAL();
            Phieu_DAL.Update(Phieu);
        }
        public static void Delete(int iD)
        {
            TinhTrang_Phieu_DAL Phieu_DAL = new TinhTrang_Phieu_DAL();
            Phieu_DAL.Delete(iD);
        }
      public static TinhTrang_PhieuCollection Get(string where,
               int pageindex,
               int pagesize,
               string orderby,
               string orderdirection,
               out int total)
        {
            TinhTrang_Phieu_DAL Phieu_DAL = new TinhTrang_Phieu_DAL();
            return Phieu_DAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
      public static TinhTrang_PhieuCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            TinhTrang_Phieu_DAL Phieu_DAL = new TinhTrang_Phieu_DAL();
            return Phieu_DAL.Get(cri.Criter, 0, 0, TinhTrang_PhieuColumns.MaTinhTrang_Phieu.ToString(), OrderDirection.ASC.ToString(), out total);
        }
      public static TinhTrang_Phieu_DTO GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, TinhTrang_PhieuColumns.MaTinhTrang_Phieu.ToString(), Condition.EQUAL, iD);
            TinhTrang_Phieu_DAL Phieu_DAL = new TinhTrang_Phieu_DAL();
            TinhTrang_PhieuCollection PhieuCollection = Phieu_DAL.Get(cri.Criter,
                0, 0, TinhTrang_PhieuColumns.MaTinhTrang_Phieu.ToString(), OrderDirection.ASC.ToString(), out total);
            if (PhieuCollection.Count > 0)
                return PhieuCollection[0];
            return null;
        }
      public static TinhTrang_PhieuCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            TinhTrang_Phieu_DAL Phieu_DAL = new TinhTrang_Phieu_DAL();
            return Phieu_DAL.Get(cri.Criter, 1, number,
                TinhTrang_PhieuColumns.MaTinhTrang_Phieu.ToString(), OrderDirection.DESC.ToString(), out total);
        }
      public static TinhTrang_PhieuCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            TinhTrang_Phieu_DAL PhieuDAL = new TinhTrang_Phieu_DAL();
            return PhieuDAL.Get(cri.Criter, 1, number,
                TinhTrang_PhieuColumns.MaTinhTrang_Phieu.ToString(), OrderDirection.DESC.ToString(), out total);
        }
    }
}
